package com.example.aaa;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {
	public static int v = 0;
	public static int currentView = R.layout.activity_main;
	public void toggleView(View v){
		currentView = (currentView == R.layout.activity_main)?R.layout.alter_activity_main:R.layout.activity_main;
		setContentView(currentView);
	}
	
	public MainActivity(){
		Log.w("constr","inst #"+(++v));
	}
    @Override
	protected void onStart(){
     	super.onStart();
     	Log.w("onStart","inst #"+v);
    }
    
    @Override
    protected void onSaveInstanceState(Bundle outState) {
    	// TODO Auto-generated method stub
    	EditText et = (EditText) findViewById(R.id.editText1);
    	super.onSaveInstanceState(outState);
    	outState.putString("editText1", et.getText().toString());
    	Log.w("onSaveInstanceState","inst #"+v);
    }
    
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
    	super.onRestoreInstanceState(savedInstanceState);
     	EditText et = (EditText) findViewById(R.id.editText1);
     	et.setText(savedInstanceState.getString("editText1")+"+Plus");
     	Log.w("onRestoreInstanceState","inst #"+v);
    }
    
    @Override
	protected void onResume(){
    	super.onResume();
    	Log.w("onResume","inst #"+v);
    }
    @Override
	protected void onPause(){
    	super.onPause();
    	Log.w("onPause","inst #"+v);
    }
    
	protected void onStop(){
    	super.onStop();
    	Log.w("onStop","inst #"+v);
    }
	
	protected void onDestroy(){
    	super.onDestroy();
    	Log.w("onDestroy","inst #"+v);
    }
	
	protected void onRestart(){
    	super.onRestart();
    	Log.w("onRestart","inst #"+v);
    }
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
